import uuid
from typing import Any

from recruit.adapter.database.models import User
from recruit.adapter.stubs.user import StubUserGateway


class UserGateway(StubUserGateway):
    def __init__(
            self,
            user_id: uuid.UUID | None,
            is_user: bool = False
    ) -> None:
        self.is_user = is_user
        self.user_id = user_id

    async def get_one(self, **kwargs: Any) -> User | None:
        if self.user_id is None:
            return None
        return User(
            id=self.user_id,
            user_id=kwargs.get('user_id') or '1',
            username='@username'
        )

    async def check_user(self, **kwargs: Any) -> bool:
        return self.is_user

    async def create(self, **kwargs: Any) -> User:
        return User(
            id=self.user_id,
            user_id='1',
            username='@username'
        )

    async def update(self, *args, **kwargs: Any) -> User:
        return User(
            id=self.user_id,
            user_id='1',
            **kwargs
        )
